﻿// HSS.ServiceModel.Internal.VirtualServiceInspector.cs
// ----------------------------------------------------------------------------
// Licensed under the MIT license
// http://www.opensource.org/licenses/mit-license.html
// ----------------------------------------------------------------------------
// HighSpeed-Solutions, LLC
// Copyright (c) 2001-2010
// ----------------------------------------------------------------------------
// File:       VirtualServiceInspector.cs
// Author:     HSS\gbanta
// Created:    08/12/2010
// Modified:   12/04/2010
// ----------------------------------------------------------------------------
namespace HSS.ServiceModel.Internal
{
	#region Using Directives
	using System.ServiceModel;
	using System.ServiceModel.Channels;
	#endregion

	#region VirtualServiceInspector
	/// <summary>
	/// VirtualServiceInspector
	/// </summary>
	[System.Diagnostics.DebuggerStepThroughAttribute()]
	internal sealed class VirtualServiceInspector : IMessageInspector
	{
		#region Constants
		private const string headerName = "VirtualServiceToken";
		private const string headerNamespace = "http://highspeed-solutions.net/ServiceModel/v100";
		#endregion

		#region Fields
		private string tokenValue;
		#endregion

		#region Constructors
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="token">The application token.</param>
		public VirtualServiceInspector(string token)
		{
			this.tokenValue = token;
		}
		#endregion

		#region Methods
		/// <summary>
		/// 
		/// </summary>
		/// <param name="request"></param>
		/// <param name="channel"></param>
		/// <returns></returns>
		public object BeforeSendRequest(ref Message request, IClientChannel channel)
		{
			request.Headers.Add(MessageHeader.CreateHeader(headerName, headerNamespace, this.tokenValue));
			return null;
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="reply"></param>
		/// <param name="correlationState"></param>
		public void AfterReceiveReply(ref Message reply, object correlationState)
		{
		}
		#endregion
	}
	#endregion
}